import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-07-30
 * Time: 19:35
 */
class Solution23 {
    public int findMinArrowShots(int[][] points) {
        Arrays.sort(points,(v1, v2)->{
            return v1[0] > v2[0] ? 1 : -1;
        });

        // 互相重叠
        // int left = points[0][0];
        int right = points[0][1],ret = 1;

        for(int i = 1; i < points.length; i++) {
            int a = points[i][0],b = points[i][1];

            if(a <= right) {
                // 无需判断左端点
                // left = Math.max(left,a);
                right = Math.min(right,b);
            }else {
                right = b;
                ret++;
            }
        }
        return ret;
    }
}

